package com.android.gl2jni

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.os.Environment
import com.android.gl2jni.encoder.MediaAudioEncoder
import com.android.gl2jni.encoder.MediaEncoder
import com.android.gl2jni.encoder.MediaMuxerWrapper
import kotlinx.android.synthetic.main.activity_record_audio.*
import net.surina.soundtouch.SoundTouch
import timber.log.Timber
import java.io.File

class RecordAudioActivity : AppCompatActivity() {
    val soundTouch = SoundTouch(44100, 2)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Timber.plant(Timber.DebugTree())
        setContentView(R.layout.activity_record_audio)
        record.setOnClickListener { startRecord() }
        soundTouch.setTempo(2f)
        var a: ByteArray = kotlin.ByteArray(10)
        var b: ByteArray = kotlin.ByteArray(20)
        var c = "abcdefghij"
        for (i in 0..9) {
            a[i] = c[i].toByte()
        }
        GL2JNILib.test(a,b)
        b.forEach {
            Timber.d("char=$it")
        }

    }
    fun startRecord() {
        soundTouch.processFile(File(Environment.getExternalStorageDirectory(), "testwav.wav").absolutePath,
                File(Environment.getExternalStorageDirectory(), "out.wav").absolutePath)
    }

}
